<?php

namespace Teachers\Controller;

use Admin\Controller\IndexController;
use Think\Controller;

/*
 * 问答系统
 * 
 *  */
class AskController extends CommonController {
    public $pagesize;

    //显示已解决的问题
    public function index() {
        //得到学校id
        $school_id = $this->showschoolID();
        $grade = I('get.grade');
        $pagesize = 20;
        $ask_dataa = $this->showAskArticle($school_id, $grade, I('get.p', 1), $pagesize, $state = 1);
        $this->assign("ask_dataa", $ask_dataa);
        $count = $this->getaskCount($school_id, $grade, $state = 1);
        $Page = new \Think\Page($count, $pagesize, $state = 0);
        $show = $Page->show(); // 分页显示输出
        $this->assign('page', $show); // 赋值分页输出
        $this->assign('url_adk', U('Teachers/Ask/index', array('grade' => $grade)));
        $this->assign('grade', $grade);
        $this->assign('url_not', U('Teachers/Ask/ask_not', array('grade' => $grade)));
        $this->display();
    }

    //显示未解决的问题
    public function ask_not() {
        $grade = I('get.grade');
        $school_id = $this->showschoolID(); //获取学校id
        $pagesize = 20;
        $ask_not = $this->showAskArticle($school_id, $grade, I('get.p', 1), $pagesize, $state = 0);
        $count = $this->getaskCount($school_id, $grade, $state = 0);
        $Page = new \Think\Page($count, $pagesize, $state = 0);
        $show_not = $Page->show(); // 分页显示输出
        $this->assign('page', $show_not); // 赋值分页输出
        $this->assign('ask_not', $ask_not);
        $this->assign('grade', $grade);
        $this->assign('url_adk', U('Teachers/Ask/index', array('grade' => $grade)));
        $this->assign('url_not', U('Teachers/Ask/ask_not', array('grade' => $grade)));
        $this->display();
    }
    /**
     * 更新问答
     * 
     * */
    public function updateask() {
        $post_data = I('post.');
        $grade = $post_data['grade'];
        if ($_POST) {
            $this->updateasks($post_data, $grade);
        }
    }
    /**
     * 删除各项类别信息
     * \
     * */
    public function deleteask() {
        $ask_id = I('post.ask_id');
        $info = $this->deleteasks($ask_id);
        $this->ajaxReturn($_POST);
    }

}
